/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import request from '@/utils/request';
import { message } from 'antd';

export async function getAliappParamsList(params: any) {
  return request('/AlipayTemplateMini/authMiniProgramList', {
    method: 'POST',
    data: params,
  }).then(({ code, data, msg }) => {
    if (code == 0 && data?.list && !!data?.list.length) {
      return {
        data: Array.isArray(data.list) ? data.list : [],
        total: data.total,
      };
    } else {
      message.error(msg);
      return {
        data: [],
        total: 0,
      };
    }
  });
}

export async function signPersonMiniProgram(params: any) {
  return request('/AlipayTemplateMini/signPersonMiniProgram', {
    method: 'POST',
    data: params,
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.success('成功');
    } else {
      message.error(msg);
    }
    return code == 0;
  });
}

export async function signPersonMiniProgramDak(params: any) {
  return request('/AlipayTemplateMini/changeMiniProgramInnAccount', {
    method: 'POST',
    data: params,
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.success('成功');
    } else {
      message.error(msg);
    }
    return code == 0;
  });
}
export async function saveMiniProgramLicense(params: any) {
  return request('/AlipayTemplateMini/saveMiniProgramLicense', {
    method: 'POST',
    data: params,
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.success('成功');
    } else {
      message.error(msg);
    }
    return code == 0;
  });
}

export async function joinMiniProgramBuildTask(params: any) {
  return request('/AlipayTemplateMini/joinMiniProgramBuildTask', {
    method: 'POST',
    data: params,
  }).then(({ code, msg }) => {
    if (code == 0) {
      message.success('成功');
    } else {
      message.error(msg);
    }
    return code == 0;
  });
}
